#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDockWidget>
#include <QPushButton>
#include <QVBoxLayout>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //创建浮动窗口
    QDockWidget* dockwidget1 = new QDockWidget("浮动窗口1");
    QDockWidget* dockwidget2 = new QDockWidget("浮动窗口2");

    this->addDockWidget(Qt::LeftDockWidgetArea, dockwidget1);
    this->addDockWidget(Qt::LeftDockWidgetArea, dockwidget2);

    //添加控件到浮动窗口中
    QPushButton* button1 = new QPushButton("按钮1");
    dockwidget1->setWidget(button1);

    //创建窗口
    QWidget* container = new QWidget();
    //创建布局管理器
    QVBoxLayout* layout = new QVBoxLayout();
    container->setLayout(layout);

    //创建其他控件
    QPushButton* button2 = new QPushButton("按钮2");
    QPushButton* button3 = new QPushButton("按钮3");
    QPushButton* button4 = new QPushButton("按钮4");
    //将控件添加到布局管理器中
    layout->addWidget(button2);
    layout->addWidget(button3);
    layout->addWidget(button4);

    dockwidget2->setWidget(container);
}

MainWindow::~MainWindow()
{
    delete ui;
}

